// miniprogram/pages/PartyArtifact/index/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    xingqingqianming:[],
    renshengyulu:[],
    qingganyulu:[],
    fojiachanyu:[],
    mingrenyulu:[],
    yingwenyulu:[],
    swiperList: [
      {
      id: 0,
      type: 'image',
      url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big39000.jpg'
    }, {
      id: 1,
      type: 'image',
      url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg'
    }, {
      id: 2,
      type: 'image',
      url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big25011.jpg'
    }, {
      id: 3,
      type: 'image',
      url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big21016.jpg'
    }, {
      id: 4,
      type: 'image',
      url: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big99008.jpg'
    }],
    shengxiaopeidui:'../../../images/shengxiaopeidui.png',
    tangshi:'../../../images/tangshi.png',
    baoxiao:'../../../images/baoxiao.png',
    zhougong:'../../../images/zhougong.png',
    jingqing:'../../../images/jinqingqidai.png',
    wallpaper:'https://q9.itc.cn/q_70/images03/20240106/502d021b58eb4c01997860f1757a0c91.jpeg',
    ScfisConversion:'../../../images/scfis.png'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    that.towerSwiper('swiperList');
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  //生肖配对
  ChineseZodiacMatched: function () {
    wx.navigateTo({
      url: '../../PartyArtifact/ChineseZodiacMatched/index',
    })
  },
  //唐诗三百首
  Tang:function(){
    wx.navigateTo({
      url: '../../PartyArtifact/300Tang/index',
    })
  },
  //上海集装箱运价指数SCFIS
  scfis:function(){
    wx.navigateTo({
      url: '../../PartyArtifact/Scfis/index',
    })
  },
  //通用接口
  tongyongjiekou:function(){
    wx.navigateTo({
      url: '../../PartyArtifact/tongyongjiekou/index',
    })
  },
  DotStyle(e) {
    this.setData({
      DotStyle: e.detail.value
    })
  },
  // cardSwiper
  cardSwiper(e) {
    this.setData({
      cardCur: e.detail.current
    })
  },
  // towerSwiper
  // 初始化towerSwiper
  towerSwiper(name) {
    let list = this.data[name];
    for (let i = 0; i < list.length; i++) {
      list[i].zIndex = parseInt(list.length / 2) + 1 - Math.abs(i - parseInt(list.length / 2))
      list[i].mLeft = i - parseInt(list.length / 2)
    }
    this.setData({
      swiperList: list
    })
  },
  // towerSwiper触摸开始
  towerStart(e) {
    this.setData({
      towerStart: e.touches[0].pageX
    })
  },
  // towerSwiper计算方向
  towerMove(e) {
    this.setData({
      direction: e.touches[0].pageX - this.data.towerStart > 0 ? 'right' : 'left'
    })
  },
  // towerSwiper计算滚动
  towerEnd(e) {
    let direction = this.data.direction;
    let list = this.data.swiperList;
    if (direction == 'right') {
      let mLeft = list[0].mLeft;
      let zIndex = list[0].zIndex;
      for (let i = 1; i < list.length; i++) {
        list[i - 1].mLeft = list[i].mLeft
        list[i - 1].zIndex = list[i].zIndex
      }
      list[list.length - 1].mLeft = mLeft;
      list[list.length - 1].zIndex = zIndex;
      this.setData({
        swiperList: list
      })
    } else {
      let mLeft = list[list.length - 1].mLeft;
      let zIndex = list[list.length - 1].zIndex;
      for (let i = list.length - 1; i > 0; i--) {
        list[i].mLeft = list[i - 1].mLeft
        list[i].zIndex = list[i - 1].zIndex
      }
      list[0].mLeft = mLeft;
      list[0].zIndex = zIndex;
      this.setData({
        swiperList: list
      })
    }
  },
  //幽默爆笑笑话
  HumorousJokes:function(){
    wx.navigateTo({
      url: '../../PartyArtifact/HumorousJokes/index',
    })
  },
  CrazyDream:function(){
    wx.navigateTo({
      url: '../../PartyArtifact/CrazyDream/index',
    })
  },
  More:function(){
    // wx.navigateTo({
    //   url: '../../PartyArtifact/More/index',
    // })
  },
  Emotional:function(){
    wx.navigateTo({
      url:'../../PartyArtifact/Emotional/index'
    })
  },
  Relax:function(){
    wx.switchTab({
      url: '../../PartyArtifact/Relax/index'
    })
  },
  Happy:function(){
    wx.switchTab({
      url: '../../PartyArtifact/Happy/index'
    })
  },
  zuowen:function(){
    wx.navigateTo({
      url: '../../PartyArtifact/composition/index',
    })
  },
  zhuangx:function(){
    wx.navigateTo({
      url: '../../PartyArtifact/PackToForce/index',
    })
  },
  wallpaper:function(){
    wx.navigateTo({
      url: '../../PartyArtifact/wallpaper/index',
    })
  },
  //scfis换算
  SCFIXConversion:function(){
    wx.navigateTo({
      url: '../../PartyArtifact/Scfis/scfis',
    })
  }
})